import LoginUser from "@/config/user";
import CommonInterface from "@/api/common-interface";
import { useEffect, useState } from "react";
import { AnyParams } from "@/common/httptypes";
import { SelectElement } from "@/common/zct-types";
export default function Index() {
    const [loading, setLoading] = useState(false)
    useEffect(() => {
        if (!LoginUser.sync().enptTypeToiD || !LoginUser.sync().enptTypeToSelect) {
            CommonInterface.enptTypeList({
                setLoading, success: (data: any) => {
                    const resSelect:SelectElement[] = []
                    const resMap: AnyParams<string> = {}
                    data.filter((p: { parentId: string; }) => p.parentId !== "0").map((p: {
                         // eslint-disable-next-line array-callback-return
                         val: string | number ; name: string; }) => {
                        resMap[p.val] = p.name;
                        resSelect.push({value:p.val,title:p.name})
                    })

                    LoginUser.saveAndFlush({ enptTypeToiD: resMap,enptTypeToSelect:resSelect })
                }
            })
        }


    }, [loading])


    return <>
        这里是LayoutHome-----

        {LoginUser.sync().userInfo?.username}

        {/* <button onClick={()=>{

    HNavigate("/demosSSS",{state: {name:'Eula',age:"18"}});

}}>按钮</button> */}
    </>
}